<?php


/**
 * Permite obtener datos de las peticiones de los clientes al servidor
 *
 * @author Robert Babilonia <bobbabilon2@gmail.com>
 */
class ClientData {
    
    
    private $ip;
    private $isp;
    
    public function getIp() {
        return $this->ip;
    }

    public function getIsp() {
        return $this->isp;
    }
 
    /**
     * Obtiene los datos de una peticion de cliente
     * 
     * 
     */

    public function __construct(){
        
        if (getenv("HTTP_X_FORWARDED_FOR")){
            $this->ip = getenv("HTTP_X_FORWARDED_FOR");
            $client = gethostbyaddr($_SERVER['HTTP_X_FORWARDED_FOR']);
          }else{
            $this->ip = getenv("REMOTE_ADDR");
            $client = gethostbyaddr($_SERVER['REMOTE_ADDR']);
           }
        $str = preg_split("/\./", $client);
        $i = count($str);
        $x = $i - 1;
        $n = $i - 2;
        
        $this->isp = $str[$n] . "." . $str[$x];
  
    }
   
}

?>
